package com.shumi.rbac.web;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.shumi.rbac.model.User;
import com.shumi.rbac.model.Yhxqxx;
import com.shumi.rbac.service.SystemService;
@RestController
@RequestMapping(value="/yhcc")
public class YhccController {
	
	@Autowired
	SystemService systemService;
	
	
	//插入用户抽查-用户详情信息操作
	@ResponseBody
	@RequestMapping(value="/yhxq")
	public Map<String,String> insertYhxq(Yhxqxx yhxqxx){
		Map map=new HashMap();
		systemService.insertYhxqxx(yhxqxx);
		map.put("data", "success");
		map.put("status", "200");
		return map;	
	}
	
	//查询用户抽查-用户详情信息操作
	@ResponseBody
	@RequestMapping(value="/yhdetail")
	public Map  yhdetail(String id,HttpSession session){
		Object object =session.getAttribute("user");
		User user=(User)object;	
		String userId=user.getUserId();
		Map map=new HashMap();
		map.put("data", systemService.yhdetail(id, userId));
		map.put("status", "200");
		return map;
		
	}
	//查询用户抽查-用户排名（镇排名）信息操作
		@ResponseBody
		@RequestMapping(value="/zpm")
		public Map  zpm(HttpSession session){
			Object object =session.getAttribute("user");
			User user=(User)object;
			String userId=user.getUserId();
			Map map=new HashMap();
			map.put("data", systemService.zpm(userId));
			map.put("status", "200");
			return map;
			
		}
		//查询用户抽查-用户排名（村排名）信息操作
		@ResponseBody
		@RequestMapping(value="/cpm")
		public Map  cpm(HttpSession session){
			Object object =session.getAttribute("user");
			User user=(User)object;
			String userId=user.getUserId();
			Map map=new HashMap();
			map.put("data", systemService.cpm(userId));
			map.put("status", "200");
			return map;
			
		}
		//查询用户抽查-用户排名（住户排名）信息操作
		@ResponseBody
		@RequestMapping(value="/zhpm")
		public Map  zhpm(HttpSession session){
			Object object =session.getAttribute("user");
			User user=(User)object;
			String userId=user.getUserId();
			Map map=new HashMap();
			map.put("data", systemService.zhpm(userId));
			map.put("status", "200");
			return map;
			
		}
		//按照镇名、村名、住户名搜索用户操作
		@ResponseBody
		@RequestMapping(value="/search")
		public Map  search(String cxxx,HttpSession session){
			Object object =session.getAttribute("user");
			User user=(User)object;
			String userId=user.getUserId();
			Map map=new HashMap();
			map.put("data", systemService.search("%"+cxxx+"%",userId));
			map.put("status", "200");
			return map;				
	}	
		
	

}
